{if (($fans['status']==2 || ($theme['endtime']+432000) < TIMESTAMP) && $system['s']['isshare']==1) }
 <script>
{else}
{php echo $config['iswxshare']==0?$register_jssdk:"<script src='https://res.wx.qq.com/open/js/jweixin-1.3.2.js'></script>";}

    <script>

      var GLat;
      var GLng;
      var orderid  = 0;
      var orderno = '';
      var isflag = false;
        var shareData = {
            title: '{$sharetitle}',
            desc: '{$sharedesc}',
            imgUrl: '{$shareimgurl}',
            link: '{$shareurl}'
        };
        wx.ready(function () {
          {if $canshare == 0}
          wx.hideOptionMenu();
          {else}
          wx.showOptionMenu();
          {/if}
          
          {if $config['locationtype']==1 && $config['iscomm']==1}
              wx.getLocation({
                  type: 'gcj02', //wgs84 或 gcj02
                  success: function (res) {
                      GLat = res.latitude; // 纬度，浮点数，范围为90 ~ -90
                      GLng = res.longitude; // 经度，浮点数，范围为180 ~ -180。
                  },
                  fail: function (res) {
                      alert('拒绝授权获取地理位置，无法获得红包！请刷新后，同意再继续！');
                  }
              });
          {/if}
            wx.onMenuShareAppMessage({
                title: shareData.title,
                desc: shareData.desc,
                link: shareData.link,
                imgUrl: shareData.imgUrl,
                trigger: function (res) {
                },
                success: function (res) {
                    
                  setTimeout(function(){
                    dosharepyq(0);
                  }, 500);
                },
                cancel: function (res) {
                },
                fail: function (res) {
                }
            });

            wx.onMenuShareTimeline({
                title: shareData.title,
                link: shareData.link,
                imgUrl: shareData.imgUrl,
                success: function () {
                  setTimeout(function(){
                    dosharepyq(1);
                    {if $config['iscomm']==1 && $config['comm41'] > 0}
                      dosharehb(); 
                    {/if}
                    {if $config['iscomm']==1 && $system['fenxiao07'] > 0}
                      doyaoyiyaohb(); 
                    {/if}
                  }, 500);
                },
                cancel: function () {
                }
            });
             	
        });

        wx.error(function (res) {
        });
        
        {/if}

        $(function(){
        	$("#show_pay_type_2").click(function() {		
        var paystoreid = $('input[name="topaycityid"]:checked').val() ;
        var status = $('#status').val();
				if(status == "0"){   					
					ds.dialog({
						title : '&#25805;&#20316;&#25552;&#31034;',
						content : '&#27963;&#21160;&#23578;&#26410;&#24320;&#22987;&#21734;',
						yesText : '&#30830;&#23450;',
					    timeout :2.5,
					});
					return false;
				}
				if(status == "2"){     					
					ds.dialog({
						title : '&#25805;&#20316;&#25552;&#31034;',
						content : '&#27963;&#21160;&#24050;&#32463;&#32467;&#26463;&#21862;',
						yesText : '&#30830;&#23450;',
					    timeout :2.5,
					});
					return false;
				}
        {if !empty($config['xieyi'])}
            if(read_ok == 0){
                show_erro("请{$config['xieyi']}");
                return false;
            }
        {elseif !empty($config['jmcontent']) }
            if(read_ok == 0){
                show_erro("请您阅读加盟规则，并同意参与");
                return false;
            }
        {/if}
        if(paystoreid < 1 || paystoreid == undefined){
            show_erro("请选择未加盟的城市");
            return false;
        }


        {if (!empty($myworker) && empty($config['isworkerpay']))} 
          ds.dialog({
            title : '&#25805;&#20316;&#25552;&#31034;',
            content : '&#21592;&#24037;&#19981;&#21487;&#20197;&#25253;&#21517;&#44;&#22914;&#38656;&#27979;&#35797;&#35831;&#29992;&#38750;&#21592;&#24037;&#24494;&#20449;&#44;&#22914;&#38656;&#24110;&#23458;&#25143;&#19979;&#21333;&#35831;&#29992;&#32447;&#19979;&#24405;&#20837;',
            yesText : '&#30830;&#23450;',
              timeout :5,
          });
          return false;
        {/if}

        {if $isyixuan == true}             
          ds.dialog({
            title : '&#25805;&#20316;&#25552;&#31034;',
            content : '&#23458;&#25143;&#27963;&#21160;&#36827;&#34892;&#20013;&#44;&#19981;&#21487;&#27979;&#35797;',
            yesText : '&#30830;&#23450;',
              timeout :2.5,
          });
          return false;
        {/if}

		    var address = $("#address_order").val();
        {if $config['shopstype'] == 0 }
          var option = $('#shoptitle option:selected').val();
        {else}
          var option = $("#shoptitle").val();
        {/if}
				var code = $('#code option:selected').val();
				var datetime = $("#date_order").val();
        var xieyi = $("input[name='xieyi']:checkbox").attr('checked');
				{if !empty($config['shops'])}
				if(option.length <=0){
					ds.dialog({
						title : '&#25805;&#20316;&#25552;&#31034;',
						content : '&#35831;&#36873;&#25321;{$config['shops']}',
						yesText : '&#30830;&#23450;',
					    timeout :2.5,
					});
					return false;
				}
				{/if}
        
        var checkid = $("input[name='check_type']:checked").val();

        if(checkid == undefined || checkid == 0){
          ds.dialog({
            title : '&#25805;&#20316;&#25552;&#31034;',
            content : '&#35831;&#36873;&#25321;&#19968;&#31181;&#21442;&#19982;&#26041;&#24335;！',
            yesText : '&#30830;&#23450;',
            timeout :2.5,
          });
          return false;
        }else if(checkid == 1){
          var joinidv = 0;
        }else if(checkid == 4){
          var joinidv = 4;
        }else if(checkid == 3){
          var joinidv = 9;
        }else{
          var joinidv = 1;
        }

				var username = $('#regname_order').val();
				var mobile = $("#username_order").val();
				if(username.length == 0){
					ds.dialog({
						title : '&#25805;&#20316;&#25552;&#31034;',
						content : '&#35831;&#36755;&#20837;{$config['nametext']}',
						yesText : '&#30830;&#23450;',
					    timeout :2.5,
					});
					return false;
				}
				if(mobile.length != 11){
					ds.dialog({
						title : '&#25805;&#20316;&#25552;&#31034;',
						content : '&#35831;&#36755;&#20837;&#49;&#49;&#20301;{$config['mobiletext']}',
						yesText : '&#30830;&#23450;',
					    timeout :2.5,
					});
					return false;
				}
				{if !empty($config['datetime'])}
					if(datetime.length <=0){
						ds.dialog({
							title : '&#25805;&#20316;&#25552;&#31034;',
							content : '&#35831;&#36873;&#25321;{$config['datetime']}',
							yesText : '&#30830;&#23450;',
						    timeout :2.5,
						});
						return false;
					}
				{/if}


				$(".chips_tanchu_bottom").hide();
    			$(".base_tcdiv_mobile1").hide();//
    			$(".chips_tanchu1").hide();
				if(isflag){
					isflag = true;
					return false;
				}
              //hidden_info();
              tips("正在支付..."); 
       		   	$.ajax({
       				 type:'POST',
                  	 dataType : "json",
       				 data:{num:num,joinid:joinidv,username : username,mobile:mobile,address:paystoreid,option:option,code:code,datetime:datetime},
       				 url:'/{php echo createMobileUrl("yxpay",array("op"=>"ready","themeid"=>$themeid,"recordid"=>$recordid,"workerid"=>$workerid,"fromuid"=>$fromuid,"fopenid"=>$fopenid));}',
       				 success:function(data){
       					 var json = data.message;
       					 console.log(json);
       					 if(json.errcode == 0){
                             if(json.payway == 0){
                                 window.location.href = json.url;
                             }else{
                                 //tips(json.tid);
                                 util.pay({
                                     orderFee : json.fee,
                                     payMethod : 'wechat',
                                     orderTitle : json.title,
                                     orderTid : json.tid,
                                     module : '{$_P['m']}',
                                     success : function(result) {
                                         {if empty($config['payedurl'])}
                                         tips2('支付成功',window.location.href);
                                         {else}
                                         tips2('支付成功','{$config["payedurl"]}');
                                         {/if}
                                     },
                                     fail : function(result) {
                                         alert('fail : ' + result.message);
                                     },
                                     complete : function(result) {
                                         location.reload();
                                     }
                                 });
                             }
       					  }else if(json.errcode == 110){
       						tips2(json.msg,json.url);
       					  }else{	 
       						tips2(json.msg,'/{php echo createMobileUrl("index",array("themeid"=>$themeid));}');
       					  }
       				 }
       			 });
	});
        })

        
		function checkorder(){
			if(orderno== ""){
				alert('定单号为空');return false;
			}
		   	$.ajax({
				 type:'POST',
				 dataType : "json",
				 data:{orderid:orderid},
				 url:'/{php echo createMobileUrl("yxpay",array("themeid"=>$themeid,"op"=>"check"));}',
				 success:function(data){
					  var json = data.message;
					  if(json.errcode == 0){
						  tips2(json.msg,json.url);
					  }else{	 
						  checkorder();
					  }
				 }
			 });
		}
        
        
    </script>